<?php
	// function isuser($name, $value, $msg, $arg){
	// 	public $username;
	// 	public $password;
	// 	$db=M("user");
	// 	$user=$db->where('username="'.$username.'"')->find();
	// 	if($value!='')
	// }

function format_time($time) {
            $now = time();
            $today = strtotime(date('Y-m-d'));//今天零点零时
            $zuotian = strtotime('-1 day', $today);//昨天零点零时
            $diff = $now - $time;//时间戳
            $str = '';
            switch ($time) {
                case $diff < 60 :
                    $str = $diff . '秒前';
                    break;
                case $diff < 3600 :
                    $str = floor($diff / 60) . '分钟前';
                    break;
                case $time > $today :
                    $str = floor($diff / 3600) . '小时前';
                    break;
                case $time > $zuotian :
                    $str = '昨天' . date('H:i:s', $time);
                    break;
                default :
                    $str = date('Y-m-d H:i:s', $time);
            }
            return $str;
        }
?>